package com.codingapi.auto.deploy.service;


import com.codingapi.auto.deploy.ato.EmailConfig;
import com.codingapi.auto.deploy.email.MailUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.mail.javamail.MimeMessageHelper;
import org.springframework.stereotype.Component;

import javax.mail.MessagingException;
import javax.mail.internet.MimeMessage;

/**
 * 邮件通知
 * @author zhangdaoning
 * @date 2018/7/24
 */
@Component
public class EmailNotifyService {
    @Autowired
    private MailUtils mailUtils;
    @Autowired
    private EmailConfig emailConfig;

    /**
     * 发送邮件
     * @param content 邮件内容
     * @param isHtml 是否是html邮件
     * @return
     */
    public boolean sendHtmlEmail(String content, boolean isHtml) {

      return  mailUtils.sendHtmlEmail(emailConfig.getDeliver(),emailConfig.getReceiver(),emailConfig.getCarbonCopy(),emailConfig.getSubject(),content,isHtml);
    }

}
